<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useStore } from 'vuex'
import HelloWorld from './HelloWorld.vue'
import http from '../utils/http.js'
const router = useRouter()
const home = () => {
  // 去首页之前，先发送一次请求
  http.get('/api/song/detail/?id=31445554&ids=[31445554]').then((res) => {
    console.log('进入首页')
    console.log(res.data)
  })

  router.push({
    name: 'home',
  })
}

const go404 = () => {
  router.push({
    name: '404',
  })
}

const goBack = () => {
  router.push({
    name: 'goBack',
  })
}

const store = useStore()
let count = store.state.num

function addCount() {
  count++
  store.state.num = count
}
</script>

<template>
  <!-- 样式绑定 -->
  <p>我是登录页</p>
  <p>我是vuex-num：{{ store.state.num }}</p>
  <p><button @click="addCount">增加num</button></p>
  <button @click="home">去首页</button>
  <button @click="go404">去404</button>
  <HelloWorld />
</template>
